package com.example.glidelearningproject.fragment.transformation;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Spinner;

import com.bumptech.glide.request.RequestOptions;
import com.example.glidelearningproject.GlideApp;
import com.example.glidelearningproject.R;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.base.XPageFragment;

import butterknife.BindView;
import butterknife.OnClick;

@Page(name = "变换类型")
public class TransformationTypeFragment extends XPageFragment {
    public static final String IMAGE_URL = "https://upload-images.jianshu.io/upload_images/24946737-0e44d74bb84020b3.jpg?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp";
    @BindView(R.id.imageView)
    ImageView imageView;
    @BindView(R.id.transformation_spinner)
    Spinner typeSpinner;
    @BindView(R.id.btnApply)
    Button btnApply;
    @Override
    protected int getLayoutId() {
        return R.layout.fragment_transformation_type;
    }

    @Override
    protected void initViews() {

    }

    @Override
    protected void initListeners() {

    }

    @OnClick(R.id.btnApply)
    protected void onClick(){
        int position = typeSpinner.getSelectedItemPosition();
        RequestOptions requestOptions = new RequestOptions();
        switch (position) {
            case 0:
                requestOptions.centerCrop();
                break;
            case 1:
                requestOptions.centerInside();
                break;
            case 2:
                requestOptions.circleCrop();
                break;
            case 3:
                requestOptions.fitCenter();
                break;
            case 4:

                break;
        }
        GlideApp.with(this)
                .load(IMAGE_URL)
                .apply(requestOptions)
                .into(imageView);
    }
}
